package com.suning.sawp.service.impl.dao;

import java.util.Date;

import javax.annotation.Resource;

import org.springframework.data.mongodb.core.MongoOperations;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;

import com.suning.sawp.intf.dao.ValidActivityDaoService;
import com.suning.sawp.po.promotion.ValidActivity;
/**
 * 
 * 鉴权过的活动列表数据库操作<br> 
 * 〈功能详细描述〉
 *
 * @author 12061818
 * @see [相关类/方法]（可选）
 * @since [产品/模块版本] （可选）
 */
@Service("validActivityDaoService")
public class ValidActivityDaoServiceImpl implements ValidActivityDaoService {

    @Resource
    MongoOperations mongoTemplate;
    
    @Override
    public void deleteValidActivityBeforeDate(Date date) {
        Query query = new Query();
        Criteria criteria = new Criteria();
        criteria.and(ValidActivity.Attributes.END_TIME).lt(date);
        query.addCriteria(criteria);
        // 删除结束时间在date之前的已鉴权活动列表数据
        mongoTemplate.remove(query, ValidActivity.class);
    }

}
